home *** CD-ROM | disk | FTP | other *** search
Text File | 1998-06-04 | 9.7 KB | 270 lines | [TEXT/MPS ] |
- #
- # File: UserStartup•VU
- #
- # Contains: Initializations for Virtual User extension in MPW
- #
- # How to use: Drop this file in your MPW Folder and then launch MPW, or,
- # open it, select all and hit enter if MPW is already running.
- #
- # Written by: Stuart Russell from original UserStartup•VU by P Nagarajan
- #
- # Copyright: © 1990-1994 by Apple Computer, Inc., all rights reserved.
- #
- # Change History:
- #
- # 02/22/90 naga creation
- # 02/07/94 SBR changed to use a Prefs file
- # 05/17/94 SBR fixed for multiple prefs items
- # 05/28/94 SBR opens prefs file as target for speed
- #
- # Sets the location of any folders needed for a module. A module is
- # defined as a folder containing things you want to use while in MPW.
- # If the folder can't be found, automatically prompts the user for it and
- # creates (or changes) a Prefs file to remember where the folder was found.
- # If you want to do any other type of setup, like inserting menu items
- # or validating server folders, you are on your own!
-
- # In general, things which need customization are either next to or surrounded
- # by commented lines beginning with #####.
-
- # To modify this startup script to work with a new module:
- # 1) Change customPrefsDir (below) to the name of the preferences folder
- # for this module. Be sure to terminate it with a colon. It can be an
- # existing folder name.
- #
- # for example:
- # set customPrefsDir "My Prefs Folder:"
- #
- # 2) Change customPrefsFile (below) to the name of the preferences file
- # for this module. Do not terminate it with a colon. It can be an
- # existing file name.
- #
- # for example:
- # set customPrefsFile "My Prefs File"
- #
- # 3) Decide how many prefs items you want and what to name them.
- # Modify, add or delete items as described below.
- #
- # 4) Locate the lines surrounded by
- # "##### begin custom statements for this module"
- # "##### end custom statements for this module"
- # Modify, delete, or add lines in this section however you want.
- # They will not execute unless all prefs items are valid.
- #
- # 5) Modify the comments beginning with "File:" and "Contains" at the
- # beginning of this file to reflect the new module.
- #
- # To modify a preference item:
- # 1) Locate the line below which says
- # "##### preference items set by this script:".
- #
- # 2) Just below that, locate the name of the prefs item you want to modify.
- #
- # 3) Replace all occurrences of that name in this file with the new name.
- #
- # 4) Locate the section below surrounded by
- # ##### begin validation for this prefs item
- # ##### end validation for this prefs item.
- #
- # 5) The first line should be the actual validation of that prefs item.
- # We look for a key file name inside the folder for the module. You
- # need to modify the key file name to make it unique.
- #
- # for example:
- #
- # The original validation line might look like:
- # if `Exists -f "{VUDir}"Startup` != ""
- # where VUDir is the old name of this prefs item, and Startup is
- # the key file.
- #
- # So you change it to
- # if `Exists -f "{newItem}"myPrefKeyFile` != ""
- # where newItem is the new name of this item as modified in 3),
- # and myPrefKeyFile is the string name of the key file inside the
- # project folder.
- #
- # 6) In the "else" clause of the validation section, just below the beep,
- # you can see the directory locator command, used in case the prefs
- # item was not valid or the directory was not found. You need to modify
- # the prompting text to tell the user which directory to find.
- #
- # for example:
- #
- # The original directory locator command line might look like:
- # (Set VUDir `getfilename -d -m 'Find old folder'`) ∑ dev:null
- # where VUDir is the old name of this prefs item, and
- # 'Find the Virtual User folder' is the old prompting text for the
- # user to locate the directory.
- #
- # So you change it to
- # (Set newItem `getfilename -d -m 'Find new folder'`) ∑ dev:null
- # where newItem is the new name of this prefs item as modified
- # in 3), and 'Find new folder' is the new prompting text.
- #
- # 7) Locate the lines surrounded by
- # "##### begin custom statements for this module"
- # "##### end custom statements for this module"
- # Modify, delete, or add lines in this section however you want.
- # They will not execute unless all prefs items are valid.
- #
- # To add a new preference item:
- # 1) Locate the line below which says
- # "##### preference items set by this script:"
- #
- # 2) Duplicate the first line below that, which should be the name of an
- # existing prefs item.
- #
- # 3) Replace the duplicated prefs item name with your new name.
- # Do not replace all!
- #
- # 4) Select the last section of this file surrounded by
- # "##### begin find or create this prefs item"
- # "##### end find or create this prefs item",
- # including the surrounding comments.
- #
- # 5) Select Copy from the Edit menu, type the right arrow key, then type
- # Return. The return inserts a blank line to keep the script readable.
- #
- # 6) Select Paste from the Edit menu.
- #
- # 7) Select the last section of this file surrounded by
- # "##### begin validation for this prefs item"
- # "##### end validation for this prefs item",
- # including the surrounding comments.
- #
- # 8) Select Copy from the Edit menu, type the right arrow key, then type
- # Return. The return inserts a blank line to keep the script readable.
- #
- # 9) Select Paste from the Edit menu.
- #
- # 10) Replace the old prefs item name with the new name you used in 3), but
- # only in the two sections you just duplicated. Do not replace all!
- #
- # 11) Replace the validation command line and the find directory command
- # line as described in 5) and 6) of the "To modify a preference item:"
- # section above.
- #
- # 12) Locate the lines surrounded by
- # "##### begin custom statements for this module"
- # "##### end custom statements for this module"
- # Modify, delete, or add lines in this section however you want.
- # They will not execute unless all prefs items are valid.
- #
- # To delete a preference item:
- # 1) Locate the line below which says
- # "##### preference items set by this script:".
- #
- # 2) Just below that, locate the name of the prefs item you want to modify,
- # and delete that line.
- #
- # 4) Delete the section of this file surrounded by
- # "##### begin find or create this prefs item"
- # "##### end find or create this prefs item"
- # which contains the prefs item you are trying to delete,
- # including its surrounding comments.
- #
- # 5) Delete the section of this file surrounded by
- # "##### begin validation for this prefs item"
- # "##### end validation for this prefs item"
- # which contains the prefs item you are trying to delete,
- # including the surrounding comments.
- #
- # 6) Delete any lines in the section in this file surrounded by
- # "##### begin custom statements for this module"
- # "##### end custom statements for this module"
- # which refer to the prefs item you are trying to delete.
- #
- # 7) Locate the lines surrounded by
- # "##### begin custom statements for this module"
- # "##### end custom statements for this module"
- # Modify, delete, or add lines in this section however you want.
- # They will not execute unless all prefs items are valid.
-
- ##### preference items set by this script:
- # VUDir
- # (Use one line for each item name)
- #####
-
- set saveExit "{exit}" # restored at the end
- set exit 0
-
- ##### custom name of the prefs folder
- set customPrefsDir "Virtual User Stuff:"
-
- ##### custom name of the prefs file
- set customPrefsFile "VU Preferences"
-
- set thePrefsDir "{systemfolder}Preferences:{customPrefsDir}"
- if (`exists -d "{thePrefsDir}"` == "")
- newFolder "{thePrefsDir}" # create prefs folder if needed
- end
-
- set thePrefsFile "{thePrefsDir}{customPrefsFile}"
- if (`exists -f "{thePrefsFile}"` == "")
- new "{thePrefsFile}" # create preferences file and
- target "{thePrefsFile}" # send it behind for speed, or
- else
- open -t "{thePrefsFile}" # open prefs file as target
- end
-
- sizeWindow 400 200 "{thePrefsFile}"
-
- ##### begin find or create this prefs item
- ##### duplicate this section for each prefs item
- find • "{thePrefsFile}"
- find /set VUDir/ "{thePrefsFile}"
- if "{status}" == "2" # item is not in prefs file yet
- set VUDir "This is a fake directory:"
- echo "Set VUDir ∂"{VUDir}∂"∂n" >> "{thePrefsFile}"
- end
- ##### end find or create this prefs item
-
-
- save "{thePrefsFile}"
- execute "{thePrefsFile}" # set all the preferences here
-
- Set exitValue 'OK'
- ##### begin validation for this prefs item
- ##### duplicate this section for each prefs item
- Set EverLooked 0
- Loop
- Break if "{exitValue}" == 'cancelled'
- if `Exists -f "{VUDir}Startup"` != ""
- if {EverLooked} == 1 # If valid, and it changed,
- find • "{thePrefsFile}" # then update the prefs file
- find /'Set VUDir'[ ∂t]+/Δ:Δ/∂n/ "{thePrefsFile}"
-
- # we cat because path may contain characters significant to: Replace
- echo -n ∂""{VUDir}"∂" | Catenate > "{thePrefsFile}".§
- save "{thePrefsFile}"
- execute "{thePrefsFile}" # set modified preferences here
- end # if it changed
-
- Break
- else
- Set EverLooked 1 # If prefs not valid, then user
- Set VUDir "" # must find the valid folder(s).
- # Beep
- (Set VUDir `getfilename -d -m 'Find the Virtual User folder'`) ∑ dev:null
- if "{VUDir}" == ""
- set exitValue 'cancelled'
- Break
- end
- end
- end
- ##### end validation for this prefs item
-
-
- if "{exitValue}" == 'OK'
- ##### begin custom statements for this module
- export "{VUDir}"
- Execute "{VUDir}"Startup
- ##### end custom statements for this module
- end
-
- close "{thePrefsFile}" # clean up
- set exit "{saveExit}"
-
- exit 0 if "{exitValue}" == 'cancelled' # Allow MPW to continue even
- exit 0 if "{exitValue}" == 'OK' # if this one was cancelled.
-